var express = require('express');
var router = express.Router();
const goodsController = require('../controllers/Ridgepole_controller');
const  cart =require('../models/Ridgepole_bean')

//增加购物车
router.post('/add', function (req, res) {
    console.log(req.body.goodsid);
    console.log(req.body.userid,req.body.goodsid,req.body.data,req.body.qty);
    goodsController.addrp(new cart.carts(req.body.userid,req.body.goodsid,req.body.data,req.body.qty),(ret) =>res.json(ret)
    ,
    (err) => res.json(err)
    )
})

//获取楼栋数据
router.get('/select', function (req, res) {
    goodsController.getrp(null,(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})


//删除数据
router.delete('/delete', function (req, res) {
    console.log(req.body.userid,req.body.qty);
   goodsController.deleterp(new cart.deltete(req.body.userid,req.body.goodsid),(ret) =>res.json(ret)
    ,
       (err) => res.json(err)
   )
})


//修改数据
router.put('/updata', function (req, res) {
    goodsController.updaterp(new cart.update(req.body.userid,req.body.goodsid,req.body.qty),(ret) =>res.json(ret)
    ,
        (err) => res.json(err)
    )
})


module.exports =router